#include "configwidget.h"

namespace verema
{

ConfigWidget::ConfigWidget()
: hbl_mainlayout()
, tab_tabwidget(this)
, cfg_db(this)
, cfg_pg(this)
{
    tab_tabwidget.insertTab(0, &cfg_db, "Datenbank");
    tab_tabwidget.insertTab(1, &cfg_pg, "Programm");

    hbl_mainlayout.addWidget(&tab_tabwidget);
    setLayout(&hbl_mainlayout);

    setWindowTitle("Einstellungen");
	setWindowModality(Qt::ApplicationModal);
	setWindowFlags(Qt::Tool);
	setFixedSize(220, 300);

	connect(&cfg_db, SIGNAL(configChanged()), this, SLOT(widgetChangedConfig()));
	connect(&cfg_pg, SIGNAL(configChanged()), this, SLOT(widgetChangedConfig()));
}

void ConfigWidget::show(int view)
{
    move(m_mainWindowPosition.x()+25, m_mainWindowPosition.y()+25);

    QWidget::show();

    cfg_db.loadData();
    cfg_pg.loadData();

    if(0 == view)
    {
        tab_tabwidget.setCurrentIndex(0);
    }
    else if(1 == view)
    {
        tab_tabwidget.setCurrentIndex(1);
    }
}

void ConfigWidget::reloadData()
{
    cfg_db.loadData();
    cfg_pg.loadData();
}


}
